package com.woniu.core.service.Impl;

import com.woniu.core.entity.CoreUser;
import com.woniu.core.mapper.CoreUserMapper;
import com.woniu.core.service.CoreUserService;
import com.woniu.util.utils.HttpResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class CoreUserServiceImpl implements CoreUserService {
    @Autowired
    private CoreUserMapper coreUserMapper;

    @Override
    public HttpResult<?> updateCoreUserPasswordByUserAccount(String account, String password) {
        coreUserMapper.updateCoreUserPasswordByUserAccount(account, password);
        return new HttpResult<>().ok();
    }

    @Override
    public HttpResult<?> selectUserByAccount(String account) {
        try {
//            QueryWrapper<CoreUser> queryWrapper = new QueryWrapper<>();
//            queryWrapper.eq("account",account);
//            CoreUser coreUser = coreUserMapper.selectOne(queryWrapper);
            CoreUser coreUser = coreUserMapper.selectUserByAccount(account);
            if(coreUser != null ){
                return new HttpResult<>().ok(coreUser);
            }
            return new HttpResult<>().fail();
        } catch (Exception e) {
          e.printStackTrace();
            return new HttpResult<>().fail();
        }
    }
}
